﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PhatPhucLoc.dao;
using PhatPhucLoc.model;

namespace PhatPhucLoc.view
{
    public partial class FormNhapKho : Form
    {
        private FormKhoHang frm = null;

        public FormNhapKho(ref FormKhoHang frm)
        {
            InitializeComponent();
            this.frm = frm;
        }

        private void btnKetThuc_Click(object sender, EventArgs e)
        {

        }

        private void btnChapNhan_Click(object sender, EventArgs e)
        {
            KhoHangModel model = new KhoHangModel();
            model.MaSanPham = cmbSanpham.SelectedValue.ToString();
            model.SoLuong = textBox1.Text;


            if (KhohangDAO.Insert(model))
                MessageBox.Show("Nhập hàng thành công ");
            else
                MessageBox.Show("Nhập hàng không thành công ");


            frm.formLoad();
            this.Dispose();
        }

        private void btnTroGiup_Click(object sender, EventArgs e)
        {
            
        }

        private void formNhapKho_Load(object sender, EventArgs e)
        {
            DataTable dt = HangHoaDAO.GetAll();

            cmbSanpham.DisplayMember = "TenHangHoa";
            cmbSanpham.ValueMember = "id";
            cmbSanpham.DataSource = dt;
        }
    }
}
